/**
 * <copyright>
 * </copyright>
 *

 */
package it.unibo.iss.domotica.domoticDsl.impl;

import it.unibo.iss.domotica.domoticDsl.Consumption;
import it.unibo.iss.domotica.domoticDsl.DomoticDslFactory;
import it.unibo.iss.domotica.domoticDsl.DomoticDslPackage;
import it.unibo.iss.domotica.domoticDsl.Elettrodomestico;
import it.unibo.iss.domotica.domoticDsl.Properties;
import it.unibo.iss.domotica.domoticDsl.Sensor;
import it.unibo.iss.domotica.domoticDsl.Usage;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class DomoticDslFactoryImpl extends EFactoryImpl implements DomoticDslFactory
{
  /**
   * Creates the default factory implementation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public static DomoticDslFactory init()
  {
    try
    {
      DomoticDslFactory theDomoticDslFactory = (DomoticDslFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.unibo.it/iss/domotica/DomoticDsl"); 
      if (theDomoticDslFactory != null)
      {
        return theDomoticDslFactory;
      }
    }
    catch (Exception exception)
    {
      EcorePlugin.INSTANCE.log(exception);
    }
    return new DomoticDslFactoryImpl();
  }

  /**
   * Creates an instance of the factory.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DomoticDslFactoryImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EObject create(EClass eClass)
  {
    switch (eClass.getClassifierID())
    {
      case DomoticDslPackage.SYSTEM: return createSystem();
      case DomoticDslPackage.PACKAGE: return createPackage();
      case DomoticDslPackage.PROPERTIES: return createProperties();
      case DomoticDslPackage.ELETTRODOMESTICO: return createElettrodomestico();
      case DomoticDslPackage.SENSOR: return createSensor();
      default:
        throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object createFromString(EDataType eDataType, String initialValue)
  {
    switch (eDataType.getClassifierID())
    {
      case DomoticDslPackage.CONSUMPTION:
        return createConsumptionFromString(eDataType, initialValue);
      case DomoticDslPackage.USAGE:
        return createUsageFromString(eDataType, initialValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String convertToString(EDataType eDataType, Object instanceValue)
  {
    switch (eDataType.getClassifierID())
    {
      case DomoticDslPackage.CONSUMPTION:
        return convertConsumptionToString(eDataType, instanceValue);
      case DomoticDslPackage.USAGE:
        return convertUsageToString(eDataType, instanceValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public it.unibo.iss.domotica.domoticDsl.System createSystem()
  {
    SystemImpl system = new SystemImpl();
    return system;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public it.unibo.iss.domotica.domoticDsl.Package createPackage()
  {
    PackageImpl package_ = new PackageImpl();
    return package_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Properties createProperties()
  {
    PropertiesImpl properties = new PropertiesImpl();
    return properties;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Elettrodomestico createElettrodomestico()
  {
    ElettrodomesticoImpl elettrodomestico = new ElettrodomesticoImpl();
    return elettrodomestico;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Sensor createSensor()
  {
    SensorImpl sensor = new SensorImpl();
    return sensor;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Consumption createConsumptionFromString(EDataType eDataType, String initialValue)
  {
    Consumption result = Consumption.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertConsumptionToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Usage createUsageFromString(EDataType eDataType, String initialValue)
  {
    Usage result = Usage.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertUsageToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DomoticDslPackage getDomoticDslPackage()
  {
    return (DomoticDslPackage)getEPackage();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @deprecated
   * @generated
   */
  @Deprecated
  public static DomoticDslPackage getPackage()
  {
    return DomoticDslPackage.eINSTANCE;
  }

} //DomoticDslFactoryImpl
